#include "Hero.h"
#include <iostream>
#include <string>
#include "Sword.h"
using namespace std;

Hero::Hero(string name, int startingHealth, int startXLocation, int startYLocation){
	this->name=name;
	health = startingHealth;
	maxHealth = startingHealth;
	damage = 3;
	level = 1;
	hasItem = false;
	gold=0;
	experience =0;
	Point startLocation(startXLocation, startYLocation);
	location = startLocation;
	
	}

string Hero::getName(){
	return name;
	}

int Hero::getDamage(){
	return damage;
	}

int Hero::getHealth(){
	return health;
	}


int Hero::getMaxHealth(){
	return maxHealth;
	}

int Hero::getLevel(){
	return level;
	}

void Hero::levelUp(){
	level++;
	maxHealth+=10;
	damage++;
	}

void Hero::heal(){
	health+=2*level;
	if (health>maxHealth)
		health = maxHealth;

	}

void Hero::takeDamage(int dmg){
	health-=dmg;
	}


void Hero::useSword(Sword* sword){
	cout<<"You take up the "<<sword->getName()<<endl;
	damage += sword->getDamage();
	hasItem=true;
	}

void Hero::layDownSword(Sword* sword){

	damage-= sword->getDamage();
	hasItem=false;

	}

bool Hero::enhanceSword(Sword * sword){
	cout<<"You lay the sword on an altar and pray to the gods to enhance your weapon."<<endl;
	int dice = rand();
	if ((dice%10)> 8){
		cout<<"The gods answer your prayers"<<endl;

		return true;
		}
	else{
		cout<<"The gods remain silent"<<endl;
		}
	return false;

	}

bool Hero::isHoldingItem(){
	return hasItem;
	}

void Hero::endGame(){
	cout<<"GAME OVER"<<endl;
	cout<<"FINAL STATS"<<endl;
	cout<<"NAME: "<<getName()<<endl;
	cout<<"LEVEL: "<<getLevel()<<endl;
	cout<<"HEALTH: "<<getHealth()<<endl;
	cout<<"DAMAGE: "<<getDamage()<<endl;
	}

void Hero::addExperience(int reward){
	experience +=reward;
	}

void Hero::addGold(int deposit){
	gold +=deposit;
	}

int Hero::getExperience(){
	return experience;
	}

int Hero::getGold(){
	return gold;
	}

bool Hero::subtractGold(int withdrawl){
	if ((gold - withdrawl) < 0)
		return false;
	else{
		gold -=withdrawl;
		return true;
		}

	}

Point Hero::getLocation(){
	return location;
	}

void Hero::setLocation(Point p){
	location = p;
	}

int Hero::getXLocation(){
	return location.getX();
	}

int Hero::getYLocation(){
	return location.getY();
	}

void Hero::moveHeroAxis(Point* p){
	location = *p;
	}







